package main

import (
	"fmt"
	"github.com/astaxie/beego/orm"
	beego "github.com/beego/beego/v2/server/web"
	_ "github.com/go-sql-driver/mysql"
	_ "org.yxk/beego-demo/routers"
	_ "org.yxk/beego-demo/utils"
)

func init() {
	// 注册驱动
	orm.RegisterDriver("mysql", orm.DRMySQL)
	var uri, _ = beego.AppConfig.String("sqlconn")
	if err := orm.RegisterDataBase("default", "mysql", uri); err != nil {
		fmt.Println("连接数据库出错")
		return
	}
	//utils.ExecSql("insert into user (name) values('33ss')")
}
func main() {
	if beego.BConfig.RunMode == "dev" {
		beego.BConfig.WebConfig.DirectoryIndex = true
		beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
	}

	fmt.Println("连接数据库成功")
	beego.Run()
}
